package com.meme.editor.gui.sprite2d;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.Icon;
import javax.swing.JToolBar;
import javax.swing.JPanel;

public class AnimatedModulePanel extends JPanel
{
	AnimatedModuleView mAnimatedModuleView;
	
	public AnimatedModulePanel (AnimatedModuleView animatedModuleView)
	{
		mAnimatedModuleView = animatedModuleView;
		
		setLayout ( new BorderLayout() );
		
		JToolBar toolbar = new JToolBar ();
		
		toolbar.setBorderPainted ( true );
		toolbar.setRollover ( true );
		toolbar.setFloatable ( false );
		
		toolbar.add(new StartPlayingAnimatedModule (null));
		toolbar.add(new StopPlayingAnimatedModule (null));

		add (toolbar, BorderLayout.NORTH);
		add (mAnimatedModuleView, BorderLayout.CENTER);
	}
	
	class StartPlayingAnimatedModule extends AbstractAction 
	{
		public StartPlayingAnimatedModule (Icon icon)
		{
			super ("Play", icon);
		}
		
	    public void actionPerformed(ActionEvent e) 
	    {
	    	mAnimatedModuleView.startPlayingAnimatedModule();
	    }
	}
	
	class StopPlayingAnimatedModule extends AbstractAction 
	{
		public StopPlayingAnimatedModule (Icon icon)
		{
			super ("Stop", icon);
		}
		
	    public void actionPerformed(ActionEvent e) 
	    {
	    	mAnimatedModuleView.stopPlayingAnimatedModule();
	    }
	}
}
